const Router = require("koa-router")
const Server = require('./server')
const Check = require('./check')
const { auth } = require('@/lib/auth')

/**
 * 路由对象
 * @type {Router}
 */
const router = new Router({
	prefix: '/ali'
})

/**
 * 阿里OSS签名
 */
router.get("/oss-signature", async (ctx, next) => {
	Check.ossSignature(ctx)
	const data = await Server.ossSignature(ctx.vals)
	ctx.sendSuccess(data)
})

/**
 * 获取OSS文件列表
 */
router.get("/oss-list", auth, async (ctx, next) =>{
	Check.ossList(ctx)
	const data = await Server.ossAll(ctx)
	ctx.sendSuccess(data)
})

/**
 * 删除OSS指定文件
 */
router.delete("/oss-remove", auth, async (ctx, next) =>{
	Check.ossRemove(ctx)
	const data = await Server.ossRemove(ctx)
	ctx.sendSuccess(data)
})

module.exports = router
